FROM php:8.1.16-fpm

ENV COMPOSER_VERSION=2.0.8
ENV REDIS_VERSION=5.3.5
ENV MONGO_VERSION=1.15.0
ENV SWOOLE_VERSION=5.0.0

COPY conf/sources.list /opt/sources.list

WORKDIR /home/wwwroot

RUN apt-get update \
    && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng-dev \
    libzip-dev \
    unixodbc-dev \
    apt-utils \
    procps \
    lsof \
    git \
    zip \
    unzip \
    libevent-dev \
    openssl \
    libssl-dev \
    libcurl4-openssl-dev \
    pkg-config \
    gcc g++ make autoconf libc-dev pkg-config

# 添加扩展并安装gd库 安装redis、pod_mysql、mongo、swoole扩展
RUN docker-php-source extract \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd pcntl \
    && docker-php-ext-install bcmath sockets zip \
    && docker-php-ext-configure opcache --enable-opcache \
    && docker-php-ext-install opcache pdo_mysql mysqli \
    && pecl install redis-${REDIS_VERSION} \
    && docker-php-ext-enable redis \
    && pecl install mongodb-${MONGO_VERSION} \
    && docker-php-ext-enable mongodb \
    && pecl install swoole-${SWOOLE_VERSION} \
    && docker-php-ext-enable swoole

# 安装compser扩展  删除软件包
ADD extend/composer-${COMPOSER_VERSION}.phar /usr/local/bin/composer
RUN chmod 755 /usr/local/bin/composer \
    && /usr/local/bin/composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
    && rm -rf /opt/*

EXPOSE 9000
